<?php

class CompleteUserInfoMapper extends BaseMapper{
	function __construct() {
		$this->keys = array(
				array("key"=>"id","type" => "integer"),
				array("key"=>"meters","type" => "integer"),
				"username","avatarUrl");
		$this->keysProfile = array(
				"firstName", "email","lastName","gender",
				"interestTags", "birthDate",
				array("key"=>"age", "type" => "integer"));
		parent::__construct();
	}
	
	function attributesMapper($attributes){
		if (!$this->keys){
			$this->keys = $attributes->getKeys();
		}
		$return = array();
		foreach($this->keys as $key){
			if (is_array($key)){
				$auxVal =$attributes->$key["key"];
				settype($auxVal , $key["type"]);
				$return[$key["key"]] = $auxVal ;
			}
			else {
				$return[$key] = (string)$attributes->$key;
			}
		}
		
		//load profile
		foreach($this->keysProfile as $key){
			if (is_array($key)){
				$auxVal =$attributes->profile->$key["key"];
				settype($auxVal , $key["type"]);
				$return[$key["key"]] = $auxVal ;
			}
			else {
				$return[$key] = (string)$attributes->profile->$key;
			}
		}
		
		return $return;
	}
	
}

?>